﻿using System.Collections.Generic;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Framework.Serialization;
using NetProtocol.POD;

namespace IQIGame.Onigao.GamePlay
{
    public class TotemResponse : SummonResponse
    {
        public string effectName;
        public List<SkillEffectivePackageResponse> packageResp = new();

        public override void OnReset()
        {
            base.OnReset();
            this.packageResp.Clear();
            this.effectName = default;
        }

        public override void Free()
        {
            ClassPool.Put(this);
        }
        
        public override void Serialize(SOutputStream _buf)
        {
            _buf.Write_int(this.unit.guid);
            _buf.Write_long(this.unit.pid);
            _buf.Write_int(this.unit.unitType);
            _buf.Write_int(this.summonerGuid);
            _buf.Write_float(this.unit.pos.x);
            _buf.Write_float(this.unit.pos.y);
            _buf.Write_string(this.effectName);
            SerializeCustomPODUtil.SerializeList(_buf, this.packageResp);
        }

        public override void DeSerialize(SInputStream _buf)
        {
            this.unit = new BattleUnitViewPOD();
            this.unit.guid = _buf.Read_int();
            this.unit.pid = _buf.Read_long();
            this.unit.unitType = _buf.Read_int();
            this.summonerGuid = _buf.Read_int();
            this.unit.pos = new Vector2POD(_buf.Read_float(), _buf.Read_float());
            this.effectName = _buf.Read_string();
            SerializeCustomPODUtil.DeSerializeList(_buf, ref this.packageResp);
        }
    }
}